#ifndef SONG_H
#define SONG_H

#include<QString>
#include<QObject>
#include<QPointer>

// #include"SongBase.h"
#include"CommonException.h"

class SongException: public CommonException{
public:
	SongException(const char *err): CommonException(err) {}
	SongException(const QString &err) : CommonException(err) {}
};

struct SongData{
	QString path;
	QString title;
	QString artist;
	QString album;
	int trackno;
	qint64 duration;
};

class Song: public QObject{
Q_OBJECT
public:
	Song(QString path);//Should be used in most cases
	Song(QString path, QString title, QString artist, QString album, short int track, qint64 duration);
	~Song();
	
	bool isValid()const;
	
	QString path()const{ return m_path; }
	QString title()const{ return m_title; }
	QString artist()const{ return m_artist; }
	QString album()const{ return m_album; }
	short int track()const{ return m_track; }
	qint64 duration()const{ return m_duration; }
	
	SongData *data()const;
	void apply(QPointer<Song> other);
signals:
	void deleted();
private:
	bool m_isValid;
	QString m_path;
	QString m_title;
	QString m_artist;
	QString m_album;
	short int m_track;
	qint64 m_duration;
	
	void _validateExists();
	void _validatePlayable();
};

#endif
